package com.youlu.campus.admin.community.controller;

import com.youlu.campus.admin.annotation.RequestActivityAuth;
import com.youlu.campus.common.base.RestResult;
import com.youlu.campus.common.base.RestResultBuilder;
import com.youlu.campus.entity.ActivityCmsConfig;
import com.youlu.campus.service.activity.ActivityCmsConfigService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RestController
public class ActivityIconConfigController {

    @Autowired
    private ActivityCmsConfigService activityCmsConfigService;

    @PostMapping("/activity/icon-config/save")
    @RequestActivityAuth(activityId = "#activityCmsConfig.activityId")
    public RestResult create(@RequestBody ActivityCmsConfig activityCmsConfig){
        activityCmsConfigService.save(activityCmsConfig);
        return RestResultBuilder.builder().success().build();
    }

    @GetMapping("/activity/icon-config/detail")
    public RestResult detail(@RequestParam("activityId") String activityId){
        return RestResultBuilder.builder().data(activityCmsConfigService.findBy(activityId)).success().build();
    }
}
